package yesjava.news.service;

import yesjava.news.dao.NewsDao;
import yesjava.news.dao.NewsDaoImpl;
import yesjava.news.entity.News;
import yesjava.news.utils.Page;

import java.util.Arrays;
import java.util.List;


public class NewsServiceImpl implements NewsService {

    private NewsDao newsDao = new NewsDaoImpl();

    public Page<News> findAll(int pageNo, int pageSize) {
        return newsDao.selectByPage(pageNo,pageSize);
    }

    @Override
    public void removeById(Integer... id) {
        newsDao.deleteById(id);
    }

    @Override
    public News getNewsById(Integer id) {
        return newsDao.selectById(id);
    }

    @Override
    public void updateById(News news) {
        newsDao.updateById(news);
    }

    @Override
    public void saveNews(News news) {
        newsDao.insertNews(List.of(news));
    }


}
